home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F40156_improvedIntegration.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-02-06  |  3.3 KB  |  89 lines

  1. <xsl:stylesheet version="1.0" 
  2. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:xalan="http://xml.apache.org/xalan"
  4. xmlns:myImproveGenerator="myImproveGenerator"
  5. xmlns:myImproveController="myImproveController" 
  6. exclude-result-prefixes="xsl xalan myImproveGenerator myImproveController"
  7. >
  8.   <xsl:import href="improve.xsl"/>
  9.   <xsl:import href="take.xsl"/> 
  10.   <xsl:import href="takeWhile.xsl"/> 
  11.   <xsl:import href="PartialSumsList.xsl"/>
  12.  
  13.   <myImproveGenerator:myImproveGenerator/>
  14.   <myImproveController:myImproveController/>
  15.   
  16.   <xsl:output indent="yes" omit-xml-declaration="yes"/>
  17.   
  18.   <xsl:template name="improvedIntegration">
  19.     <xsl:param name="pFun" select="/.."/>
  20.     <xsl:param name="pA"/>
  21.     <xsl:param name="pB"/>
  22.     <xsl:param name="pEpsRough" select="0.0001"/>
  23.     <xsl:param name="pEpsImproved" select="0.0000001"/>
  24.  
  25.      <xsl:variable name="vMyImproveGenerator" select="document('')/*/myImproveGenerator:*[1]"/>
  26.      <xsl:variable name="vMyImproveController" select="document('')/*/myImproveController:*[1]"/>
  27.      
  28.      <xsl:variable name="vrtfRoughResults">
  29.         <xsl:call-template name="partialSumsList">
  30.             <xsl:with-param name="pFun" select="$pFun"/>
  31.             <xsl:with-param name="pA" select="$pA"/>
  32.             <xsl:with-param name="pB" select="$pB"/>
  33.             <xsl:with-param name="pEps" select="$pEpsRough"/>
  34.         </xsl:call-template>
  35.      </xsl:variable>
  36.  
  37.     <xsl:variable name="vrtfResults">
  38.         <xsl:call-template name="takeWhile">
  39.           <xsl:with-param name="pGenerator" select="$vMyImproveGenerator"/>
  40.           <xsl:with-param name="pParam0" select="xalan:nodeset($vrtfRoughResults)/*"/>
  41.           <xsl:with-param name="pController" select="$vMyImproveController"/>
  42.           <xsl:with-param name="pContollerParam" select="$pEpsImproved"/>
  43.         </xsl:call-template>
  44.     </xsl:variable>
  45.     
  46.     <xsl:variable name="vResults" select="xalan:nodeset($vrtfResults)/*"/>
  47.     <xsl:value-of select="$vResults[last()]/*[2]"/>
  48.     
  49.      <!-- <xsl:copy-of select="xalan:nodeset($vrtfResults)/*"/>  -->
  50.     
  51.   </xsl:template>
  52.   
  53.   <xsl:template name="myImproveGenerator" match="*[namespace-uri()='myImproveGenerator']">
  54.      <xsl:param name="pList" select="/.."/>
  55.      <xsl:param name="pParams" select="/.."/>
  56.      
  57.      <xsl:choose>
  58.        <xsl:when test="not($pList)">
  59.          <xsl:call-template name="improve">
  60.             <xsl:with-param name="pList" select="$pParams"/>
  61.          </xsl:call-template>
  62.        </xsl:when>
  63.        <xsl:otherwise>
  64.          <xsl:call-template name="improve">
  65.             <xsl:with-param name="pList" select="$pList[last()]/*"/>
  66.          </xsl:call-template>
  67.        </xsl:otherwise>
  68.      </xsl:choose>
  69.  
  70.   </xsl:template>
  71.   
  72.   <xsl:template name="MyImproveController" match="*[namespace-uri()='myImproveController']">
  73.     <xsl:param name="pList" select="/.."/>
  74.     <xsl:param name="pParams" select="0.01"/>
  75.     
  76.     <xsl:choose>
  77.       <xsl:when test="count($pList) < 2">1</xsl:when>
  78.       <xsl:otherwise>
  79.         <xsl:variable name="vDiff" select="$pList[last()]/*[2] 
  80.                                           - $pList[last() - 1]/*[2]"/>
  81.         <xsl:if test="not($vDiff < $pParams 
  82.                      and $vDiff > (0 - $pParams))
  83.                      and count($pList) <= 5
  84.                      ">1</xsl:if>
  85.       </xsl:otherwise>
  86.     </xsl:choose>
  87.   
  88.   </xsl:template>
  89. </xsl:stylesheet>